home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / programming / other / cyberxxxsrc / decoder / txt / adpcm.h next >
C/C++ Source or Header  |  1999-02-08  |  2KB  |  46 lines

  1. #include "Decode.h"
  2.  
  3. short indexTable[16]={
  4.  -1,-1,-1,-1, 2, 4, 6, 8,
  5.  -1,-1,-1,-1, 2, 4, 6, 8
  6. };
  7.  
  8. short stepSizeTable[89]={
  9.       7,    8,    9,   10,   11,   12,   13,   14,   16,   17,
  10.      19,   21,   23,   25,   28,   31,   34,   37,   41,   45,
  11.      50,   55,   60,   66,   73,   80,   88,   97,  107,  118,
  12.     130,  143,  157,  173,  190,  209,  230,  253,  279,  307,
  13.     337,  371,  408,  449,  494,  544,  598,  658,  724,  796,
  14.     876,  963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
  15.    2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
  16.    5894, 6484, 7132, 7845, 8630, 9493,10442,11487,12635,13899,
  17.   15289,16818,18500,20350,22385,24623,27086,29794,32767
  18. };
  19.  
  20. /* /// "calcDVI" */
  21. #define calcDVI(valpred,delta,index,step) \
  22. { long vpdiff, sign;                      \
  23.   index+=indexTable[delta];               \
  24.   if (index<0)                            \
  25.     index=0;                              \
  26.   else                                    \
  27.     if (index>88) index=88;               \
  28.   sign=delta & 8;                         \
  29.   delta=delta & 7;                        \
  30.   vpdiff=step >> 3;                       \
  31.   if (delta & 4) vpdiff+=step;            \
  32.   if (delta & 2) vpdiff+=step>>1;         \
  33.   if (delta & 1) vpdiff+=step>>2;         \
  34.   if (sign)                               \
  35.     valpred-=vpdiff;                      \
  36.   else                                    \
  37.     valpred+=vpdiff;                      \
  38.   if (valpred>32767)                      \
  39.     valpred=32767;                        \
  40.   else                                    \
  41.     if (valpred<-32768) valpred=-32768;   \
  42.   step=stepSizeTable[index];              \
  43. }
  44. /* \\\ */
  45.  
  46.